"""

64894ce562ff15cee53e60ec337a68fc3518de89bf05fffa13c0bdf294634c8d


"""
f = "1728564089u3ZoyVeU1728564089"

import hashlib
import time
import math
import random

# 获取指定个数的随机字符串
def get_random_str(num):
    # 100
    s = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
    c = ""

    for i in range(num):
        r = random.random() * len(s)
        index = math.floor(r)  # [0, 99)
        c += s[index]

    return c

# 构建请求头
def get_headers():
    headers = {}
    # 获取时间戳
    s = math.ceil(time.time())

    # 获取随机字符串
    h = get_random_str(9)
    f = str(s) + h + str(s)
    sha256 = hashlib.sha256()
    sha256.update(f.encode("utf-8"))

    signature = sha256.hexdigest()

    headers["x-tif-signature"] = signature
    headers["x-tif-timestamp"] = s
    headers["x-tif-nonce"] = h
    headers["Accept"] = "application/json"
    headers["contenttype"] = "application/x-www-form-urlencoded"
    headers["x-tif-paasid"] = "undefined"

    return headers


